﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Admin.Master" Inherits="System.Web.Mvc.ViewPage<IEnumerable<Hotnet.Entity.ViewListVideo>>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	视频管理
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
	<div>
		<div style=" font-size:x-large">视频管理</div>
		<div style=" margin:15px 0px 3px 39px;">
			<span style=" color:Red;">
				所在位置:
			</span>
			<a href="/AdminVideo/Index/?categoryID=<%=ViewData["CategoryID"] %>" style=" text-decoration:none;">
				<%=ViewData["CategoryName"] %>
			</a>
			->
			单视频管理
		</div>
	</div>

	<div  style="border:1px solid gray; padding:5px; margin-left:39px;">
		<div style="margin:3px;">
			<a style=" float:right;" href="/AdminVideo/Create/?CategoryID=<%=ViewData["CategoryID"] %>">创建视频</a>
			<a style=" color:Red;" href="javascript:void(0)">单视频管理</a>
			<a href="/AdminVideoGroup/Index?categoryID=<%=ViewData["CategoryID"] %>">视频组管理</a>
		</div>
		<div class="divDot"></div>

	<%Html.BeginForm("Index", "AdminVideo", new { categoryid = ViewData["CategoryID"] }); %>
		<div style=" text-align:center; margin-top:10px;">
				<span>
					视频名称:<%=Html.TextBox("VideoName", null, new { style="width:80px;" })%>
				</span>
				<span>
					来源网站:<%=Html.DropDownList("SourceFromID", Hotnet.Web.Controllers.Admin.AdminVideoController.VideoNetList)%>
				</span>
				
				<span>
					排序:<%=Html.DropDownList("OrderType", ConvertEnumToSelectList.ComposeSelectListFromEnum<EnumOrder>().Reverse())%>
				</span>
				<span>
					状态:<%=Html.DropDownList("IsPublished", ConvertEnumToSelectList.ComposeSelectListFromEnum<EnumPublishState>().Reverse())%>
				</span>
				<input type="submit" value="搜索" />
		</div>
	<%Html.EndForm(); %>
	</div>
	<ul class="videolist">
		<% foreach (var item in Model)
	 { %>
		<li>
			<div style=" padding:5px; float:left;">
				<img src="<%= Html.Encode(item.CoverImagePath) %>" alt="视频封面"/>
			</div>
			<span>
				名称:<span style="color:Red;"><%= Html.Encode(item.Name) %></span>
			</span>
			<div>
				<span>
					来源:<%= Html.Encode(item.SourceFromName) %>
					(<%= Html.Encode(String.Format("{0:g}", item.AddTime)) %>)
				</span>
			</div>
			<div>
				播放:<%= Html.Encode(item.IsCanPlayInner) == "True" ? "内部播放" : "外部播放"%>(<%=Html.Encode(item.ClickCount)%>)
			</div>
			<div>
				<%--列表:<span id="spanDeleteList<%=item.VideoID %>">
						<%= Html.Encode(item.DefineType==null?"":Convert.ToString((EnumDefineType)item.DefineType))%>
					</span>
				<%=item.DefineType==null?"":(int)item.DefineType!=-1?"<a id='aDeleteList"+item.VideoID+"' href='javascript:deleteInList("+item.VideoID+")'>撤出列表</a>":"" %>
				--%>
				<a href="/adminVideo/SetVideoList/<%=item.VideoID %>">设置列表</a>
			</div>
			<div>
				<a href="/AdminVideo/Edit/<%=Html.Encode(item.VideoID) %>">编辑</a>
				<a href="javascript:preview('<%=Html.Encode(item.VideoSrc) %>')">预览</a>
				<a href="javascript:deleteVideo('<%=item.VideoID %>')">删除</a>
				<a href="javascript:setPublished(<%=item.VideoID %>);" id="setP<%=item.VideoID %>" <%=(item.IsPublished==1?"style='display:none;'":"") %>>发布</a>
				<a href="javascript:unSetPublished(<%=item.VideoID %>);" id="unsetP<%=item.VideoID %>" <%=(item.IsPublished==1?"":"style='display:none;'") %> >取消发布</a>
			</div>
		</li>

		<% } %>
	</ul>
	<div>
		<%Html.RenderPartial("PaginateHelper", ViewData["PaginateHelper"] as PaginateHelper); %>
	</div>
	<div id="flashPreview" style="display:none;">
		
	</div>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ScriptContent" runat="server">
	<script type="text/javascript">
		var flashBoxy;
		var flashCodePart1 = "<embed src='";
		var flashCodePart2 = "' id='flashEmbed'"
							+ "'quality='high' width='480' height='400' align='middle' allowScriptAccess='sameDomain' type='application/x-shockwave-flash'>'"
							+ "</embed>";
		function preview(src) {
			var flashCode = flashCodePart1 + src + flashCodePart2;
			$("#flashPreview").html(flashCode);
			if (flashBoxy == null)
				flashBoxy = new Boxy($('#flashPreview'), { modal: false, title: '视频预览', closeText: '[×]', draggable: true });
			else
				flashBoxy.show();
		}

		$(document).ready(
			function() {
				
				$("#DefineType option[value='-1']").html("全部");
			}
		);


			function setPublished(videoID) {

				$.ajax(
			{
				url: "/AdminVideo/SetPublished/",
				data: "videoID=" + videoID,
				type: "post",
				success: function() {
				document.getElementById("setP" + videoID).style.cssText = "display:none";
				document.getElementById("unsetP" + videoID).style.cssText = "";
				}
			}
			);
			}
			function unSetPublished(videoID) {

				$.ajax(
			{
				url: "/AdminVideo/UnSetPublished/",
				data: "videoID=" + videoID,
				type: "post",
				success: function() {
				document.getElementById("setP" + videoID).style.cssText = "";
				document.getElementById("unsetP" + videoID).style.cssText = "display:none";
				}
			}
			);
			}
		

			function deleteVideo(videoID) {
				if (!confirm("确认删除此视频?"))
					return;
				$.post("/AdminVideo/Delete/" + videoID,
				function(data) {
				if (data.toUpperCase() == "TRUE")
						alert("删除成功！");
					window.location.href = window.location.href;
				});

			}

			function deleteInList(videoID) {
				$.post("/AdminVideo/DeleteInList/" + videoID,
				function(data) {
					if (data.toUpperCase() != "TRUE") {
						alert("撤出失败！");
						return;
					}
					$("#spanDeleteList" + videoID).html("None");
					$("#aDeleteList" + videoID).remove();
				});
			}
	
	</script>

</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="StyleContent" runat="server">
	<style type="text/css">
		.videolist
		{
			list-style-image:none;
			list-style-position:outside;
			list-style-type:none;
			
		}
		.videolist img
		{
			 width:110px;
			 height:90px;
			
		}
		.videolist li
		{
			 clear:left;
			 border:1px gray solid;
			 padding-bottom:5px;
			 margin-bottom:1px;
		}
		.divDot
		{
			border-bottom:1px solid gray; 
			border-bottom-style:dotted;
			margin:8px 0px 8px 0px;
		}
	
	</style>
</asp:Content>
